package com.sigmatrix.h5.web.ins.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.sigmatrix.h5.exception.MessageException;
import com.sigmatrix.h5.service.InspectionRecordsService;
import com.sigmatrix.h5.web.BaseController;
import com.sigmatrix.h5.web.Result;
import com.sigmatrix.h5.web.args.InsParam;
import com.sigmatrix.h5.web.args.SaveInsParam;
import com.sigmatrix.h5.web.mode.Inspection;
import com.sigmatrix.sc.jdbc.common.lang.Page;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 
 *@ClassName: InspectionController
 *@Description: 稽查controller
 *@author MH
 *@date 2017年9月25日 下午6:18:40
 */
@Api(tags="稽查")
@RestController
@RequestMapping("/ins/ins")
public class InspectionController extends BaseController{
	
	@Autowired
	InspectionRecordsService inspectionRecordsService;
	
	/**
	 * 
	 *@Title: list
	 *@Description: 查询列表
	 *@return Result
	 *@author MH
	 *@date 2017年9月26日 上午9:14:27
	 *@param vo
	 *@return
	 */
	@ApiOperation("查询稽查列表")
	@GetMapping("list")
	public Result<Page<Inspection>> list(InsParam vo){
		Page<Inspection> page = inspectionRecordsService.list(vo, vo.getPageNo(), vo.getPageSize());
		return ok(page);
	}
	
	/**
	 * 
	 *@Title: detail
	 *@Description: 查询详情
	 *@return Result
	 *@author MH
	 *@date 2017年9月26日 上午9:18:51
	 *@param id
	 *@return
	 * @throws MessageException 
	 */
	@ApiOperation("查询详情")
	@GetMapping("detail")
	public Result<Inspection> detail(Long id){
		Inspection vo = inspectionRecordsService.detail(id);
		return ok(vo);
	}
	
	/**
	 * 
	 *@Title: save
	 *@Description: 保存
	 *@return Result
	 *@author MH
	 *@date 2017年9月30日 下午1:35:21
	 *@param request
	 *@param vo
	 *@return
	 * @throws MessageException 
	 */
	@ApiOperation("保存")
	@PostMapping("save")
	public Result<String> save(@RequestBody SaveInsParam vo){
		inspectionRecordsService.save(vo,remoteAddr());
		return ok("");
	}

}
